package com.artmofang.service.Impl;
import com.artmofang.common.utils.MD5Utils;
import com.artmofang.mapper.ErpUserMapper;
import com.artmofang.pojo.ArtOaUser;
import com.artmofang.service.ErpUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class ErpUserServiceImpl implements ErpUserService {
    @Autowired
    ErpUserMapper erpUserMapper;
    @Override
    public List<ArtOaUser> queryUserInfo(String username, String password) {
        Example example = new Example(ArtOaUser.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("ou_username", username);
        try {
            criteria.andEqualTo("ou_password", MD5Utils.MD5Str(password));
        } catch (Exception e) {
            e.printStackTrace();
        }

        List<ArtOaUser> list =  erpUserMapper.selectByExample(example);


        for(ArtOaUser o:list){
            o.setOu_password(null);
        }

        return list;
    }
}
